﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HumanResourceManagementSystem.DataAccessLayer;
using System.Data;

namespace HumanResourceManagementSystem.BusinessLogicLayer
{
    class EmployeeManagement
    {
        public static DataTable getEmployeeByName(string name)
        {
            return SQL.getEmployeeByName(name);
        }

        public static DataTable getEmployeeByID(int empID)
        {
            return SQL.getEmployeeByID(empID);
        }

        public static bool empAssign(string sEmpID, int projID, string goal)
        {
            try
            {
                int empID = Convert.ToInt32(sEmpID);
                if (projID <= 0) return false;
                else return SQL.empAssign(empID, projID, goal);
            }
            catch
            {
                return false;
            }
        }

        public static int empAssign(List<int> empIDList, int projID, string goal)
        {
            int nResult = 0;
            if (projID > 0)
            {
                foreach (int empID in empIDList)
                {
                    if (SQL.empAssign(empID, projID, goal)) nResult++;
                }
            }
            return nResult;
        }

        public static bool empoyeeExisted(string sEmpID)
        {
            int empID;
            try
            {
                empID = Convert.ToInt32(sEmpID);
                return SQL.empoyeeExisted(empID);
            }
            catch
            {
                return false;
            }
        }
    }
}
